package com;

import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
import javax.swing.*;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;

/**
 * Diseño de un panel para ser usado en la clase Dialog
 * este contiene informacion accerca de la app
 * 
 * @author Alex Munoz Dominguez and Mauricio Orellana Galaz
 * @version 13-07-2012
 */
public class About extends JPanel
{
    /**
     * Constructor de Objetos de la clase About
     */
    public About()
    {
        super();
        this.setLayout(new GridBagLayout());
        JLabel img = new JLabel();
        String path = "Icons/gnotravex-logo.png";  
        URL url = this.getClass().getResource(path);  
        ImageIcon icon = new ImageIcon(url);
        img.setIcon(icon);
        this.add(img,this.datosGrid(0,0));
        
        JLabel title = new JLabel(CommandNames.APP_NAME, JLabel.CENTER);
        title.setFont(new Font("Helvetica", Font.BOLD, 30));
        this.add(title, this.datosGrid(0,1));
        
        JTextPane jta = new JTextPane();
        SimpleAttributeSet attribs = new SimpleAttributeSet();  
        StyleConstants.setAlignment(attribs , StyleConstants.ALIGN_CENTER);  
        jta.setParagraphAttributes(attribs,true); 
        jta.setText(CommandNames.DETAILS_APP);
        jta.setEditable(false);
        jta.setBackground(null);
        this.add(jta,this.datosGrid(0, 2));
       
        JTextPane jtp = new JTextPane();
        StyleConstants.setAlignment(attribs , StyleConstants.ALIGN_CENTER);  
        jtp.setParagraphAttributes(attribs,true); 
        jtp.setText(CommandNames.DATOS_MAINTAINER);
        jtp.setEditable(false);
        jtp.setBackground(null);
        this.add(jtp, this.datosGrid(0, 3));  
    }
    
    /**
     * Permite simplificar el uso del gridBagLayout 
     * 
     * @param gridx ubicacion en x en el grid
     * @param gridy ubicacion en y en el grid
     * @return GridBagConstraints con los parametros establecidos
     */
    public GridBagConstraints datosGrid(int gridx, int gridy)
    {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.fill = GridBagConstraints.CENTER;
        gbc.gridx = gridx;
        gbc.gridy = gridy;
        
        return gbc;
    }
}
